/**
 * Created by henian.xu on 2018/3/27.
 *
 */
const {getLoader} = require('react-app-rewired');
const utils = require('./config/utils');

module.exports = function(config, env) {
    console.log(env);
    if (env === 'development') {
        let {rules} = config.module;
        const styleLoaders = utils.styleLoaders({sourceMap: true, usePostCSS: true});

        rules.some((rule, index) => {
            console.log(String(rule), String(/\.css$/));
            if (String(rule.test) === String(/\.css$/)) {
                console.log(rule);
                rules.splice(index, 1);
                return false;
            }
        });

        config.module.rules = [
            ...rules,
            ...styleLoaders,
        ];
    }
    return config;
};
